package com.imau.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/response1")
public class Response1 extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {


        //1.设置响应头信息
        resp.setHeader("content-type","text/html;charset=utf-8");

        //2.设置响应状态,一般不设置
        resp.setStatus(200);

        //3.设置响应体
        //  resp.getWriter().write("<h1>响应成功!!!</h1>");

        //4.重定向到页面html
        resp.sendRedirect("admin/a.html");


    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req,resp);
    }
}
